import 'package:flutter/material.dart';
import 'package:ljy_flutter/change_notifier_proxy_privoder_ex/pages/page_a.dart';
import 'package:ljy_flutter/change_notifier_proxy_privoder_ex/pages/page_b.dart';

class ChangeNotifierProxyProviderExample extends StatefulWidget {
  const ChangeNotifierProxyProviderExample({super.key});

  @override
  State<ChangeNotifierProxyProviderExample> createState() =>
      _ChangeNotifierProxyProviderExampleState();
}

class _ChangeNotifierProxyProviderExampleState
    extends State<ChangeNotifierProxyProviderExample> {
  var _selectedIndex = 0;
  final _pages = [PageA(), PageB()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pages[_selectedIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _selectedIndex,
        onTap: (value) {
          setState(() {
            _selectedIndex = value;
          });
        },
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.book), label: '书籍列表'),
          BottomNavigationBarItem(icon: Icon(Icons.favorite), label: '收藏'),
        ],
      ),
    );
  }
}
